package com.sscw.task.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.sscw.task.entity.MRankPushCoinsPO;
import com.sscw.task.mapper.MRankPushCoinsMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Repository
@AllArgsConstructor
public class MRankPushCoinsDAO extends BaseDAO<MRankPushCoinsMapper, MRankPushCoinsPO> {

    public List<MRankPushCoinsPO> findWeekRankList(LocalDate startOfWeek, LocalDate endOfWeek, Integer size) {
        LambdaQueryWrapper<MRankPushCoinsPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MRankPushCoinsPO::getStartDate, startOfWeek);
        queryWrapper.eq(MRankPushCoinsPO::getEndDate, endOfWeek);
        queryWrapper.orderByDesc(MRankPushCoinsPO::getPushCoinsValue);
        queryWrapper.last("limit 0," + size);
        return getBaseMapper().selectList(queryWrapper);
    }

}
